package com.hjm.project.ActPaymentType.ActPaymentType.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.ActPaymentType.ActPaymentType.domain.ActPaymentType;
import com.hjm.project.ActPaymentType.ActPaymentType.service.IActPaymentTypeService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 支付类型Controller
 * 
 * @author ActPaymentType
 * @date 2020-11-29
 */
@Controller
@RequestMapping("/ActPaymentType/ActPaymentType")
public class ActPaymentTypeController extends BaseController
{
    private String prefix = "ActPaymentType/ActPaymentType";

    @Autowired
    private IActPaymentTypeService actPaymentTypeService;

    @RequiresPermissions("ActPaymentType:ActPaymentType:view")
    @GetMapping()
    public String ActPaymentType()
    {
        return prefix + "/ActPaymentType";
    }

    /**
     * 查询支付类型列表
     */
    @RequiresPermissions("ActPaymentType:ActPaymentType:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ActPaymentType actPaymentType)
    {
        startPage();
        List<ActPaymentType> list = actPaymentTypeService.selectActPaymentTypeList(actPaymentType);
        return getDataTable(list);
    }

    /**
     * 导出支付类型列表
     */
    @RequiresPermissions("ActPaymentType:ActPaymentType:export")
    @Log(title = "支付类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ActPaymentType actPaymentType)
    {
        List<ActPaymentType> list = actPaymentTypeService.selectActPaymentTypeList(actPaymentType);
        ExcelUtil<ActPaymentType> util = new ExcelUtil<ActPaymentType>(ActPaymentType.class);
        return util.exportExcel(list, "ActPaymentType");
    }

    /**
     * 新增支付类型
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存支付类型
     */
    @RequiresPermissions("ActPaymentType:ActPaymentType:add")
    @Log(title = "支付类型", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ActPaymentType actPaymentType)
    {
        return toAjax(actPaymentTypeService.insertActPaymentType(actPaymentType));
    }

    /**
     * 修改支付类型
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ActPaymentType actPaymentType = actPaymentTypeService.selectActPaymentTypeById(id);
        mmap.put("actPaymentType", actPaymentType);
        return prefix + "/edit";
    }

    /**
     * 修改保存支付类型
     */
    @RequiresPermissions("ActPaymentType:ActPaymentType:edit")
    @Log(title = "支付类型", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ActPaymentType actPaymentType)
    {
        return toAjax(actPaymentTypeService.updateActPaymentType(actPaymentType));
    }

    /**
     * 删除支付类型
     */
    @RequiresPermissions("ActPaymentType:ActPaymentType:remove")
    @Log(title = "支付类型", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(actPaymentTypeService.deleteActPaymentTypeByIds(ids));
    }
}
